﻿// Fill out your copyright notice in the Description page of Project Settings.


#include "OtherWorld/Public/Character/OtherWorldCharacterBase.h"
#include "PaperFlipbookComponent.h"
#include "GameFramework/CharacterMovementComponent.h"


AOtherWorldCharacterBase::AOtherWorldCharacterBase()
{
	PrimaryActorTick.bCanEverTick = true;
	//为了使精灵能够受场景的光源影响，能够受其他物体遮挡影响，需要将精灵组件的材质设置为 MaskedLitSpriteMAterial
	UPaperFlipbookComponent* SpriteFlipbookComponent = GetSprite();
	//动态的加载材质
	UMaterialInterface* MaskedLitSpriteMaterial = LoadObject<UMaterialInterface>(nullptr, TEXT("/Paper2D/MaskedLitSpriteMaterial.MaskedLitSpriteMaterial"));
	SpriteFlipbookComponent->SetMaterial(0, MaskedLitSpriteMaterial);
	//设置投射阴影
	SpriteFlipbookComponent->SetCastShadow(true);

	//设置精灵组件的旋转为绝对旋转
	SpriteFlipbookComponent->SetUsingAbsoluteRotation(true);
	//设置角色方向朝向移动方向
	GetCharacterMovement()->bOrientRotationToMovement = true;
	//角色最大移动速度
	GetCharacterMovement()->MaxWalkSpeed = MaxMoveSpeed;
	//设置角色的旋转速率
	GetCharacterMovement()->RotationRate = FRotator(0.0f, RotationRate, 0.0f);
}

void AOtherWorldCharacterBase::BeginPlay()
{
	Super::BeginPlay();
	
}

void AOtherWorldCharacterBase::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

